import sys
import pandas as pd
import geopandas as gpd


def filter_rows(input_csv_file, input_geojson_file, join_column_name,join_operation):
    csv_df = pd.read_csv(input_csv_file)
    gdf = gpd.read_file(input_geojson_file)
    merged_gdf = gdf.merge(csv_df, on=join_column_name, how=join_operation)
    output_file_name = 'merged.geojson'
    merged_gdf.to_file(output_file_name, driver='GeoJSON')


if __name__ == '__main__':
    print("arguments passed to the script are :",sys.argv)
    input_csv_file = sys.argv[1]
    input_geojson_file = sys.argv[2]
    join_column_name = sys.argv[3]
    join_operation = sys.argv[4]

    filter_rows(input_csv_file, input_geojson_file, join_column_name,join_operation)
